package com.pkk.penguin.frame.know.java.Javacoreknowledge.lock.base;

import com.pkk.penguin.frame.know.java.Javacoreknowledge.lock.LockVo;
import lombok.Builder;
import org.apache.commons.lang3.StringUtils;

/**
 * @description: 线程
 * @author: peikunkun
 * @create: 2020-01-13 17:35
 **/
@Builder
public class LockThread extends Thread {

  private LockVo lockVo;

  /**
   * 线程名称
   */
  private String threadName;

  public LockThread(LockVo lockVo, String threadName) {
    if (StringUtils.isNotBlank(threadName)) {
      setName(threadName);
    }
    this.lockVo = lockVo;
  }


  public LockThread(LockVo lockVo) {
    this.lockVo = lockVo;
  }

  /**
   * If this thread was constructed using a separate
   * <code>Runnable</code> run object, then that
   * <code>Runnable</code> object's <code>run</code> method is called;
   * otherwise, this method does nothing and returns.
   * <p>
   * Subclasses of <code>Thread</code> should override this method.
   *
   * @see #start()
   * @see #stop()
   */
  @Override
  public void run() {
    lockVo.run();
  }
}
